cmake_minimum_required(VERSION 2.8)

#project Tests
project(Tests)

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/builds/lib/")

IF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)")
   # Use the highest warning level for visual studio.
   SET(CMAKE_CXX_WARNING_LEVEL 4)
   IF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
     STRING(REGEX REPLACE "/W[0-4]" "/W4"
            CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
   ELSE(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
   ENDIF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
ENDIF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)")

#Generate a list of source files
file(
	GLOB_RECURSE
	source_files
	src/*.cpp
)

file(
	GLOB_RECURSE
	public_header_files
	publicInterfaces/*.h
)

file(
	GLOB_RECURSE
	private_header_files
	privateInterfaces/*.h
)

#prerequisites
include_directories(
	publicInterfaces
	privateInterfaces
	${Boost_INCLUDE_DIRS}
)

link_directories(${Boost_LIBRARY_DIRS})
link_directories(../builds/lib)

SET(ALL_LINKED_LIBS 
	${Boost_LIBRARIES}	
)

include_directories(../Objects/publicInterfaces)
include_directories(../Math/publicInterfaces)
include_directories(../Image/publicInterfaces)

# Executable for all tests
add_executable(
	Tests
	${source_files}
	${public_header_files}
	${private_header_files}
)

SOURCE_GROUP("Misc" FILES src/Main.cpp)
SOURCE_GROUP("Objects" REGULAR_EXPRESSION Objects/.*\\.cpp)
SOURCE_GROUP("Math" REGULAR_EXPRESSION Math/.*\\.cpp)
SOURCE_GROUP("Image" REGULAR_EXPRESSION Image/.*\\.cpp)
target_link_libraries(
	Tests
	Objects
	Math
	Image
	${ALL_LINKED_LIBS}
)

get_target_property(Tests_EXE Tests_all LOCATION)

add_custom_Target(
	RUN_TESTS
	${Tests_EXE} --report_level=no
	DEPENDS Tests_all
)
